package com.example.yunJie.digitalSentry.mapper.one;


import com.example.yunJie.digitalSentry.entity.ShiftEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.io.Serializable;
import java.util.List;

public interface ShiftMapper {
//    @Insert("<script> insert into sz_shift(shiftId,shiftName,startTime,endTime,marketId,postId)\n" +
//            "        values(#{shiftId},#{shiftName},#{startTime},#{endTime},#{marketId},#{postId})</script>")
    int insert(ShiftEntity shiftEntity);

//    @Update("<script>update sz_shift\n" +
//            "        <trim prefix=\"SET\" suffixOverrides=\",\">\n" +
//            "            <if test=\"shiftId != null\">shiftId = #{shiftId},</if>\n" +
//            "            <if test=\"shiftName != null\">shiftName = #{shiftName},</if>\n" +
//            "            <if test=\"startTime != null\">startTime = #{startTime},</if>\n" +
//            "            <if test=\"endTime != null\"> endTime = #{endTime},</if>\n" +
//            "            <if test=\"marketId != null\">marketId = #{marketId},</if>\n" +
//            "            <if test=\"postId != null\">postId = #{postId},</if>\n" +
//            "\n" +
//            "        </trim>\n" +
//            "        where id = #{id}</script>")
    int update(ShiftEntity shiftEntity);

//    @Delete("<script>delete from sz_shift where id = #{Id}</script>")
    int deleteById(Serializable id);

//    @Delete("<script>delete from sz_shift where id in\n" +
//            "        <foreach collection=\"array\" item=\"id\" open=\"(\" separator=\",\" close=\")\">\n" +
//            "            #{id}\n" +
//            "        </foreach></script>")
    int deleteIdList(Long[] idList);

//    @Select("<script>select *\n" +
//            "        from sz_shift\n" +
//            "        where id = #{id}</script>")
    ShiftEntity findId(String id);

//    @Select("<script>SELECT * FROM sz_shift\n" +
//            "            left join sz_post on sz_post.id = sz_shift.postId\n" +
//            "            LEFT JOIN sz_market on sz_shift.marketId = sz_market.id\n" +
//            "            <where>\n" +
//            "                <if test=\"postName != null and postName != ''\"> and  sz_shift.postId = ( SELECT sz_post.id FROM sz_post where sz_post.postName = #{postName})</if>\n" +
//            "                <if test=\"marketName != null and marketName != ''\">and sz_shift.marketId = (  SELECT sz_market.id from sz_market where sz_market.marketName = #{marketName})</if>\n" +
//            "                <if test=\"shiftName != null and shiftName != ''\">  and sz_shift.shiftName = #{shiftName}</if>\n" +
//            "            </where></script>")
    List<ShiftEntity> findAll(ShiftEntity shiftEntity);

    //根据市场名称和岗位名称查找班次名称列表
//    @Select("<script>SELECT * FROM sz_shift where sz_shift.postId = (\n" +
//            "            SELECT sz_post.postId FROM sz_post where sz_post.postName = #{postName}\n" +
//            "        )and sz_shift.marketId = (\n" +
//            "            SELECT sz_market.marketId from sz_market where sz_market.marketName = #{marketName}\n" +
//            "        )</script>")
    List<ShiftEntity> findByMarketNameAndPostName(String marketName,String postName);


    //根据市场名称和岗位名称查找班次列表
//    @Select("<script>SELECT * FROM sz_shift where sz_shift.postId = (\n" +
//            "            SELECT sz_post.postId FROM sz_post where sz_post.postName = #{postName}\n" +
//            "        )and sz_shift.marketId = (\n" +
//            "            SELECT sz_market.marketId from sz_market where sz_market.marketName = #{marketName}\n" +
//            "        )</script>")
    List<ShiftEntity> findAllByMarketNameAndPostName(String marketName,String postName);

    //根据市场名称查找所有班次
//    @Select("<script>SELECT * FROM sz_shift where sz_shift.marketId =  (\n" +
//            "            SELECT sz_market.marketId from sz_market where sz_market.marketName = #{marketName}\n" +
//            "        )</script>")
    List<ShiftEntity> findAllByMarketName(String marketName);

    //根据市场名，岗位名，班次名查找班次列表
//    @Select("<script>SELECT * FROM sz_shift where sz_shift.postId = (\n" +
//            "            SELECT sz_post.postId FROM sz_post where sz_post.postName = #{postName}\n" +
//            "        )and sz_shift.marketId = (\n" +
//            "            SELECT sz_market.marketId from sz_market where sz_market.marketName = #{marketName}\n" +
//            "        )and sz_shift.shiftName = #{shiftName}</script>")
    List<ShiftEntity> findAllByMarketNameAndPostNameAndShiftName(String marketName,String postName,String shiftName);

    //根据班次名查找班次
//    @Select("<script>select * from sz_shift where shiftName = #{shiftName}</script>")
    ShiftEntity findByShiftName(String shiftName);

    ShiftEntity findBy(String marketName,String postName,String shiftName);

}
